package kr.saeildadim.androidexam_saeildamil.chapter17;

import kr.saeildadim.androidexam_saeildamil.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Ch17_CustomTap extends Activity {
	View mPage1, mPage2, mPage3;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch17_customtap);
		
		mPage1 = findViewById(R.id.ch17_customtap_linelay1);
		mPage2 = findViewById(R.id.ch17_customtap_linelay2);
		mPage3 = findViewById(R.id.ch17_customtap_tv1);
		
		((Button)findViewById(R.id.ch17_customtap_radiobtn1)).setOnClickListener(mClickListener);
		((Button)findViewById(R.id.ch17_customtap_radiobtn2)).setOnClickListener(mClickListener);
		((Button)findViewById(R.id.ch17_customtap_radiobtn3)).setOnClickListener(mClickListener);
	}
	Button.OnClickListener mClickListener = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
				switch(v.getId()){
				case R.id.ch17_customtap_radiobtn1:
					ChangePage(1);
					break;
				case R.id.ch17_customtap_radiobtn2:
					ChangePage(2);
					break;
					
				case R.id.ch17_customtap_radiobtn3:
					ChangePage(3);
					break;
				}
			
		}

		 void ChangePage(int page) {
			mPage1.setVisibility(View.INVISIBLE);
			mPage2.setVisibility(View.INVISIBLE);
			mPage3.setVisibility(View.INVISIBLE);
			
			switch(page){
			case 1:
				mPage1.setVisibility(View.VISIBLE);
				break;
			case 2:
				mPage2.setVisibility(View.VISIBLE);
				break;
			case 3:
				mPage3.setVisibility(View.VISIBLE);
				break;
			}
		 }
	};
}
